﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using eAssessment.lists;
using System.Collections.Generic;
using eAssessment.SPLinqLern;
using System.Web;
using eAssessment.Classes.Misc;


namespace eAssessment.Webparts.ShowActiveAssessments
{
    public partial class ShowActiveAssessmentsUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ListAccessManager mgr = new ListAccessManager();
                List<AssessmentType> assessments = mgr.GetAssessmentActiveList();

                //Tabelle aufbauen
                foreach (AssessmentType item in assessments)
                {
                    TableRow row = new TableRow();
                    TableCell titelCell = new TableCell();
                    TableCell starttimeCell = new TableCell();
                    TableCell endtimeCell = new TableCell();
                    titelCell.Text = item.Titel;
                    starttimeCell.Text = item.StartTime.ToString();
                    endtimeCell.Text = item.EndTime.ToString();

                    row.Cells.Add(titelCell);
                    row.Cells.Add(starttimeCell);
                    row.Cells.Add(endtimeCell);
                    assessmentTable.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                //Erst Tabellen-Header leeren
                assessmentTable_Name.Text = "";
                assessmentTable_StartTime.Text = "";
                assessmentTable_EndTime.Text = "";
                //Dann Fehlermeldung in dafuer reserviertem Label ausgeben.
                assessmentTable_errorMessage.Text = Language.getString("error_createTable");

                Console.WriteLine(ex);
            }

            
          
        }
    }
}
